package zgate

import (
	"encoding/json"
)

type Message struct {
	Cmd uint16
	Data []byte
	Json ZJson
}
func (this*Message)Data2Json() (ZJson,error){
	err := json.Unmarshal(this.Data,&this.Json)
	return this.Json,err
}
func NewMessage(cmd uint16,data ZJson) *Message {
	m := &Message{
		Cmd:cmd,
	}
	if data == nil{
		data = ZJson{}
	}
	m.Data = data.Encode()
	return m
}
